package com.zmn.oms.services.impl.chan.pay;

import com.zmn.oms.model.entity.chan.pay.AbnormalPayment;
import com.zmn.oms.persistence.interfaces.chan.pay.AbnormalPaymentDAO;
import com.zmn.oms.services.interfaces.chan.pay.AbnormalPaymentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 类描述：
 *
 * @author lhl
 * @date 2021/01/25 15:12
 */
@Service("abnormalPaymentService")
public class AbnormalPaymentServiceImpl implements AbnormalPaymentService {

    @Resource
    private AbnormalPaymentDAO abnormalPaymentDAO;

    /**
     * 查询指定订单号的非正常支付信息
     * @param orderId
     * @return
     */
    @Override
    public List<AbnormalPayment> listByOrderId(Long orderId) {
        return abnormalPaymentDAO.listByOrderId(orderId);
    }

    /**
     * 保存
     * @param model
     * @return
     */
    @Override
    public int save(AbnormalPayment model) {
        if (model.getFacadeId() == null) {
            model.setFacadeId(0);
        }
        if (model.getCreateTime() == null) {
            model.setCreateTime(new Date());
        }
        return abnormalPaymentDAO.insert(model);
    }
}
